package com.qf.dao;

import com.qf.pojo.entity.ShopCart;
import com.qf.pojo.resp.CartGoodsResp;
import com.qf.pojo.resp.CartResp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName ShopCartMapper
 * @Description TODO
 * @Author Windy
 * @Date 2022/9/28 20:58
 * @Version 1.0
 **/
@Mapper
public interface ShopCartMapper {

    @Select("SELECT g.id,g.goods_name as goodsName,g.goods_message as goodsMessage , g.goods_price as goodsPrice," +
            " g.goods_pic as goodsPic, g.goods_material as goodsMaterial,g.goods_number as goodsNumber,g.goods_feature " +
            "as goodsFeature,sc.goods_number as number,sc.goods_money as money FROM  shop_cart sc,goods g WHERE " +
            "sc.goods_id=g.id AND sc.user_id=#{uid}")
    List<CartGoodsResp> findCartUser(int uid);

    @Select("select id, user_id as userId, goods_id as goodsId, goods_number as goodsNumber, goods_money as goodsMoney" +
            " from shop_cart where goods_id=#{arg1} and user_id=#{arg0}")
    ShopCart getCartGoods(int uid, int gid);

  
    @Select("update shop_cart set goods_number=#{goodsNumber}, goods_money=#{goodsMoney}" +
            " where user_id=#{userId} and goods_id=#{goodsId}")
    void updateAddCart(ShopCart shopCart);

    @Insert("insert into shop_cart values(0,#{userId},#{goodsId},#{goodsNumber},#{goodsMoney})")
    void addCart(ShopCart shopCart);

    @Delete("delete from shop_cart where goods_id=#{arg1} and user_id=#{arg0}")
    void delCartGoods(int uid, int gid);

    @Delete("delete from  shop_cart where user_id=#{uid}")
    void cleanCaet(int uid);
}
